<?php

namespace App\Component\Response;

use Hyperf\HttpMessage\Stream\SwooleStream;
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;

class Response extends \Hyperf\HttpServer\Response{

    public function json($data): PsrResponseInterface
    {
        return parent::json([
            'status'=>'SUCCESS',
            'data'=>$data
        ]);
    }

    public function html($data): PsrResponseInterface
    {
        return $this->getResponse()
            ->withAddedHeader('content-type', 'text/html; charset=utf-8')
            ->withBody(new SwooleStream($data));
    }
}